package com.easidea.tim.dao.purchase;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springside.core.dao.extend.HibernateEntityExtendDao;

import com.easidea.tim.entity.purchase.PurchaseOrderItem;

public class PurchaseOrderItemDao extends HibernateEntityExtendDao<PurchaseOrderItem> {
 public void deleteItemsByOrderId(long orderId) {
	List<PurchaseOrderItem> items = this.getItemsByOrderId(orderId);
	this.getHibernateTemplate().deleteAll(items);
 }
 public void savePurchaseOrderItem(PurchaseOrderItem item){
	 this.getHibernateTemplate().save(item);
 }
 @SuppressWarnings("unchecked")
public List<PurchaseOrderItem> getItemsByOrderId(long orderId) {
	 Criteria ca = this.createUnDeletedCriteria();
	 ca.add(Restrictions.eq("purchaseOrder.id", orderId));
	 return ca.list();
 }
}
